Component({
    data: {
        video: [], //基地视频
        bottom_buttonText: '上传视频'
    },
    methods: {
        afterRead(event) {
            const { file } = event.detail;
            wx.showLoading({
                title: '上传中',
                mask: true
            })
            let that = this
            setTimeout(function() {
                let { video } = that.data
                video.push('1')
                that.setData({ video: video })
                wx.hideLoading({
                    success() {
                        wx.showToast({
                            title: '上传成功',
                            icon: 'success'
                        })
                    }
                })
            }, 2000)
            // wx.uploadFile({
            //     url: 'https://example.weixin.qq.com/upload',
            //     filePath: file.url,
            //     name: 'file',
            //     formData: { user: 'test' },
            //     success(res) {
            //         // 上传完成需要更新 fileList
            //         const { fileList = [] } = this.data;
            //         fileList.push({ ...file, url: res.data });
            //         this.setData({ fileList });
            //     },
            // });
        },
        pre_vedio() {
            wx.previewMedia({
                sources: [{
                    url: '../../test.mp4',
                    type: 'video'
                }]
            })
        }
    },
    observers: {
        'video': function() {
            if (this.data.video.length === 0) {
                this.setData({ bottom_buttonText: '上传视频' })
            } else {
                this.setData({ bottom_buttonText: '修改视频' })
            }
        }
    }
})